package com.tarena.lbs.marketing.web.controller;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.marketing.web.service.ActivityService;
import com.tarena.lbs.pojo.marketing.param.ActivityParam;
import com.tarena.lbs.pojo.marketing.vo.ActivityVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ActivityController {
    //service repo mapper
    @Autowired
    private ActivityService activityService;
    //后台活动管理的 分页查询
    @PostMapping("/admin/marketing/marketingActivity/info/list")
    public Result<PageResult<ActivityVO>> activityPage()
        throws BusinessException{
        return new Result<>(activityService.activityPage());
    }

    //后台活动新增
    @PostMapping("/admin/marketing/marketingActivity/info/save")
    public Result<Void> activityAdd(@RequestBody ActivityParam param)throws BusinessException{
        activityService.activityAdd(param);
        return Result.success();
    }
    //手机小程序查看活动详情
    @GetMapping("/admin/marketing/marketingActivity/info/detail/{id}")
    public Result<ActivityVO> detail(@PathVariable("id") Integer id)
        throws BusinessException{
        return new Result<>(activityService.detail(id));
    }
}
